package org.hgvc.webapp.ets.spring.dao;

import java.util.List;

import org.hgvc.webapp.ets.bo.Complaint;
import org.hgvc.webapp.ets.constant.CommonConstant;
import org.hibernate.Query;
import org.jocsb.base.AbstractHibernateDao;


public class ComplaintHbmDao extends AbstractHibernateDao {

	public List<Complaint> getComplaintListByRefIdType(String refId,String type)throws Exception{
		StringBuffer stringBuffer = new StringBuffer();
		stringBuffer.append(" select comp from Complaint comp where comp.refId=:refId ");
		stringBuffer.append(" and comp.isDeleted=:value and comp.type=:type ");
		
		Query query = getSession().createQuery(stringBuffer.toString());
		query.setParameter("refId", refId);
		query.setParameter("value", CommonConstant.NOT_DELETED);
		query.setParameter("type", type);
		
		return (List<Complaint>)query.list();
	}
	
	public List<Complaint> getComplaintListByStatus(String status)throws Exception{
		StringBuffer stringBuffer = new StringBuffer();
		stringBuffer.append(" select comp from Complaint comp where comp.isDeleted=:value ");
		stringBuffer.append(" and comp.status=:status ");
		
		Query query = getSession().createQuery(stringBuffer.toString());
		query.setParameter("value", CommonConstant.NOT_DELETED);
		query.setParameter("status", status);
		
		return (List<Complaint>)query.list();
	}
	
	
}
